package com.aids_malaria.http.response;

import android.arch.persistence.room.Embedded;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.arch.persistence.room.TypeConverter;
import android.arch.persistence.room.TypeConverters;
import android.support.annotation.NonNull;

import com.aids_malaria.http.request.ConSymptom;
import com.aids_malaria.http.request.MicroResults;
import com.aids_malaria.http.request.Symptom;
import com.aids_malaria.util.GsonUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.litesuits.orm.db.annotation.NotNull;
import com.litesuits.orm.db.enums.AssignType;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
@Entity(tableName = "diagnosisInfoPack",primaryKeys = {"identity_code","record_no"})
public class DiagnosisInfoPack implements Serializable {

    @NonNull
    private String identity_code; //身份码
    private int record_no; //诊断记录号
    private int diagnosis_result; //诊断结果 0 正常 1 确诊病例 2 疑似病例
    private String report_time; // 报告时间
    private String report_unit; //报告单位
    private String reportor; // 报告人
    @Embedded(prefix = "symptom_")
    private Symptom clinical_symptoms; // 临床症状
    private String clinical_symptoms_json; // 临床症状
    @Embedded(prefix = "con_symptoms_")
    private ConSymptom con_symptoms; // 兼症
    private String con_symptoms_json; // 兼症
    private String onset_place; // 发病地点
    private String diagnostics; // 诊断者
    private String diagnostic_time; // 诊疗时间
    @Embedded(prefix = "micro_results")
    private MicroResults micro_results; // 镜检结果
    private String micro_results_json; // 镜检结果
    private float protozoan_density; // 原虫密度
    private float gametophyte_carry_rate; // 配子体携带率
    private float mtf_gametophyte_rate; // 雌雄配子体比率
    private String micro_examiner; // 镜检者
    private String micro_time; // 镜检时间
    @Embedded(prefix = "rdt_result")
    private MicroResults rdt_result; // rdt检查结果
    private String rdt_result_json; // rdt检查结果
    private String rdt_checker; // rdt检查人
    private int is_roea; // 2周内是否有其他流行区居留史  1 是；0否
    private String ea_place; // 流行区地点
    private String oea_place; // 其它流行区地点
    private int is_visitor_fever; // 近1月内家庭成员或来访亲友是否有人发热
    private int infection_source_type; // 感染来源分类  1本县感染2省内外县感染3外省感染4境外感染
    private String investor;
    private String create_time;
    private String update_time;
    private String onset_place_detail;
    private String rdt_check_time;
    private int is_transfusion_twoweek; //发病前2周内是否有输血史
    private String invest_time;

    private String onset_county_name; // 发病地点
    private String onset_village_name;
    private String ea_county_name; // 流行区地点
    private String ea_village_name;

    private boolean createOrUpdate = false;

    public boolean isCreateOrUpdate() {
        return createOrUpdate;
    }

    public void setCreateOrUpdate(boolean createOrUpdate) {
        this.createOrUpdate = createOrUpdate;
    }

    public String getOnset_county_name() {
        return onset_county_name;
    }

    public void setOnset_county_name(String onset_county_name) {
        this.onset_county_name = onset_county_name;
    }

    public String getOnset_village_name() {
        return onset_village_name;
    }

    public void setOnset_village_name(String onset_village_name) {
        this.onset_village_name = onset_village_name;
    }

    public String getEa_county_name() {
        return ea_county_name;
    }

    public void setEa_county_name(String ea_conuty_name) {
        this.ea_county_name = ea_conuty_name;
    }

    public String getEa_village_name() {
        return ea_village_name;
    }

    public void setEa_village_name(String ea_village_name) {
        this.ea_village_name = ea_village_name;
    }

    public static DiagnosisInfoPack copyFromNoPack(DiagnosisInfo diagnosisInfo){
        DiagnosisInfoPack diagnosisInfoPack = new DiagnosisInfoPack();
        diagnosisInfoPack.setIdentity_code(diagnosisInfo.getIdentity_code());
        diagnosisInfoPack.setRecord_no(diagnosisInfo.getRecord_no());
        diagnosisInfoPack.setDiagnosis_result(diagnosisInfo.getDiagnosis_result());
        diagnosisInfoPack.setReport_time(diagnosisInfo.getReport_time());
        diagnosisInfoPack.setReport_unit(diagnosisInfo.getReport_unit());
        diagnosisInfoPack.setReportor(diagnosisInfo.getReportor());
        // 临床症状
        String clinical_symptoms = diagnosisInfo.getClinical_symptoms();
        Symptom symptom = GsonUtil.gsonToBean(clinical_symptoms, Symptom.class);
        diagnosisInfoPack.setClinical_symptoms(symptom);
        diagnosisInfoPack.setClinical_symptoms_json(clinical_symptoms);
        //  兼症
        String con_symptoms = diagnosisInfo.getCon_symptoms();
        diagnosisInfoPack.setCon_symptoms_json(con_symptoms);
        ConSymptom conSymptom = GsonUtil.gsonToBean(con_symptoms, ConSymptom.class);
        diagnosisInfoPack.setCon_symptoms(conSymptom);

        diagnosisInfoPack.setOnset_place(diagnosisInfo.getOnset_place());
        diagnosisInfoPack.setDiagnostics(diagnosisInfo.getDiagnostics());
        diagnosisInfoPack.setDiagnostic_time(diagnosisInfo.getDiagnostic_time());
        //  镜检结果
        String micro_results = diagnosisInfo.getMicro_results();
        diagnosisInfoPack.setMicro_results_json(micro_results);
        MicroResults microResults = GsonUtil.gsonToBean(micro_results, MicroResults.class);
        diagnosisInfoPack.setMicro_results(microResults);

        diagnosisInfoPack.setProtozoan_density(diagnosisInfo.getProtozoan_density());
        diagnosisInfoPack.setGametophyte_carry_rate(diagnosisInfo.getGametophyte_carry_rate());
        diagnosisInfoPack.setMtf_gametophyte_rate(diagnosisInfo.getMtf_gametophyte_rate());
        diagnosisInfoPack.setMicro_examiner(diagnosisInfo.getMicro_examiner());
        diagnosisInfoPack.setMicro_time(diagnosisInfo.getMicro_time());

        //  rdt检查结果
        String rdt_result = diagnosisInfo.getRdt_result();
        diagnosisInfoPack.setRdt_result_json(rdt_result);
        MicroResults rdtResult = GsonUtil.gsonToBean(rdt_result, MicroResults.class);
        diagnosisInfoPack.setRdt_result(rdtResult);

        diagnosisInfoPack.setRdt_checker(diagnosisInfo.getRdt_checker());
        diagnosisInfoPack.setIs_roea(diagnosisInfo.getIs_roea());
        diagnosisInfoPack.setEa_place(diagnosisInfo.getEa_place());
        diagnosisInfoPack.setOea_place(diagnosisInfo.getOea_place());
        diagnosisInfoPack.setIs_visitor_fever(diagnosisInfo.getIs_visitor_fever());
        diagnosisInfoPack.setInfection_source_type(diagnosisInfo.getInfection_source_type());
        diagnosisInfoPack.setInvestor(diagnosisInfo.getInvestor());
        diagnosisInfoPack.setCreate_time(diagnosisInfo.getCreate_time());
        diagnosisInfoPack.setUpdate_time(diagnosisInfo.getUpdate_time());
        diagnosisInfoPack.setOnset_place_detail(diagnosisInfo.getOnset_place_detail());
        diagnosisInfoPack.setRdt_check_time(diagnosisInfo.getRdt_check_time());
        diagnosisInfoPack.setIs_transfusion_twoweek(diagnosisInfo.getIs_transfusion_twoweek());
        diagnosisInfoPack.setInvest_time(diagnosisInfo.getInvest_time());

        return diagnosisInfoPack;
    }

    private int busy_type;

    public int getBusy_type() {
        return busy_type;
    }

    public void setBusy_type(int busy_type) {
        this.busy_type = busy_type;
    }

    public String getClinical_symptoms_json() {
        return clinical_symptoms_json;
    }

    public void setClinical_symptoms_json(String clinical_symptoms_json) {
        this.clinical_symptoms_json = clinical_symptoms_json;
    }

    public String getCon_symptoms_json() {
        return con_symptoms_json;
    }

    public void setCon_symptoms_json(String con_symptoms_json) {
        this.con_symptoms_json = con_symptoms_json;
    }

    public String getMicro_results_json() {
        return micro_results_json;
    }

    public void setMicro_results_json(String micro_results_json) {
        this.micro_results_json = micro_results_json;
    }

    public String getRdt_result_json() {
        return rdt_result_json;
    }

    public void setRdt_result_json(String rdt_result_json) {
        this.rdt_result_json = rdt_result_json;
    }

    public String getIdentity_code() {
        return identity_code;
    }

    public void setIdentity_code(String identity_code) {
        this.identity_code = identity_code;
    }

    public int getRecord_no() {
        return record_no;
    }

    public void setRecord_no(int record_no) {
        this.record_no = record_no;
    }

    public int getDiagnosis_result() {
        return diagnosis_result;
    }

    public void setDiagnosis_result(int diagnosis_result) {
        this.diagnosis_result = diagnosis_result;
    }

    public String getReport_time() {
        return report_time;
    }

    public void setReport_time(String report_time) {
        this.report_time = report_time;
    }

    public String getReport_unit() {
        return report_unit;
    }

    public void setReport_unit(String report_unit) {
        this.report_unit = report_unit;
    }

    public String getReportor() {
        return reportor;
    }

    public void setReportor(String reportor) {
        this.reportor = reportor;
    }

    public Symptom getClinical_symptoms() {
        return clinical_symptoms;
    }

    public void setClinical_symptoms(Symptom clinical_symptoms) {
        this.clinical_symptoms = clinical_symptoms;
    }

    public ConSymptom getCon_symptoms() {
        return con_symptoms;
    }

    public void setCon_symptoms(ConSymptom con_symptoms) {
        this.con_symptoms = con_symptoms;
    }

    public String getOnset_place() {
        return onset_place;
    }

    public void setOnset_place(String onset_place) {
        this.onset_place = onset_place;
    }

    public String getDiagnostics() {
        return diagnostics;
    }

    public void setDiagnostics(String diagnostics) {
        this.diagnostics = diagnostics;
    }

    public String getDiagnostic_time() {
        return diagnostic_time;
    }

    public void setDiagnostic_time(String diagnostic_time) {
        this.diagnostic_time = diagnostic_time;
    }

    public MicroResults getMicro_results() {
        return micro_results;
    }

    public void setMicro_results(MicroResults micro_results) {
        this.micro_results = micro_results;
    }

    public float getProtozoan_density() {
        return protozoan_density;
    }

    public void setProtozoan_density(float protozoan_density) {
        this.protozoan_density = protozoan_density;
    }

    public float getGametophyte_carry_rate() {
        return gametophyte_carry_rate;
    }

    public void setGametophyte_carry_rate(float gametophyte_carry_rate) {
        this.gametophyte_carry_rate = gametophyte_carry_rate;
    }

    public float getMtf_gametophyte_rate() {
        return mtf_gametophyte_rate;
    }

    public void setMtf_gametophyte_rate(float mtf_gametophyte_rate) {
        this.mtf_gametophyte_rate = mtf_gametophyte_rate;
    }

    public String getMicro_examiner() {
        return micro_examiner;
    }

    public void setMicro_examiner(String micro_examiner) {
        this.micro_examiner = micro_examiner;
    }

    public String getMicro_time() {
        return micro_time;
    }

    public void setMicro_time(String micro_time) {
        this.micro_time = micro_time;
    }

    public MicroResults getRdt_result() {
        return rdt_result;
    }

    public void setRdt_result(MicroResults rdt_result) {
        this.rdt_result = rdt_result;
    }

    public String getRdt_checker() {
        return rdt_checker;
    }

    public void setRdt_checker(String rdt_checker) {
        this.rdt_checker = rdt_checker;
    }

    public int getIs_roea() {
        return is_roea;
    }

    public void setIs_roea(int is_roea) {
        this.is_roea = is_roea;
    }

    public String getEa_place() {
        return ea_place;
    }

    public void setEa_place(String ea_place) {
        this.ea_place = ea_place;
    }

    public String getOea_place() {
        return oea_place;
    }

    public void setOea_place(String oea_place) {
        this.oea_place = oea_place;
    }

    public int getIs_visitor_fever() {
        return is_visitor_fever;
    }

    public void setIs_visitor_fever(int is_visitor_fever) {
        this.is_visitor_fever = is_visitor_fever;
    }

    public int getInfection_source_type() {
        return infection_source_type;
    }

    public void setInfection_source_type(int infection_source_type) {
        this.infection_source_type = infection_source_type;
    }

    public String getInvestor() {
        return investor;
    }

    public void setInvestor(String investor) {
        this.investor = investor;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public String getOnset_place_detail() {
        return onset_place_detail;
    }

    public void setOnset_place_detail(String onset_place_detail) {
        this.onset_place_detail = onset_place_detail;
    }

    public String getRdt_check_time() {
        return rdt_check_time;
    }

    public void setRdt_check_time(String rdt_check_time) {
        this.rdt_check_time = rdt_check_time;
    }

    public int getIs_transfusion_twoweek() {
        return is_transfusion_twoweek;
    }

    public void setIs_transfusion_twoweek(int is_transfusion_twoweek) {
        this.is_transfusion_twoweek = is_transfusion_twoweek;
    }

    public String getInvest_time() {
        return invest_time;
    }

    public void setInvest_time(String invest_time) {
        this.invest_time = invest_time;
    }

    @Override
    public String toString() {
        return "DiagnosisInfoPack{" +
                "identity_code='" + identity_code + '\'' +
                ", record_no=" + record_no +
                ", diagnosis_result=" + diagnosis_result +
                ", report_time='" + report_time + '\'' +
                ", report_unit='" + report_unit + '\'' +
                ", reportor='" + reportor + '\'' +
                ", clinical_symptoms=" + clinical_symptoms +
                ", con_symptoms=" + con_symptoms +
                ", onset_place='" + onset_place + '\'' +
                ", diagnostics='" + diagnostics + '\'' +
                ", diagnostic_time='" + diagnostic_time + '\'' +
                ", micro_results=" + micro_results +
                ", protozoan_density=" + protozoan_density +
                ", gametophyte_carry_rate=" + gametophyte_carry_rate +
                ", mtf_gametophyte_rate=" + mtf_gametophyte_rate +
                ", micro_examiner='" + micro_examiner + '\'' +
                ", micro_time='" + micro_time + '\'' +
                ", rdt_result=" + rdt_result +
                ", rdt_checker='" + rdt_checker + '\'' +
                ", is_roea=" + is_roea +
                ", ea_place='" + ea_place + '\'' +
                ", oea_place='" + oea_place + '\'' +
                ", is_visitor_fever=" + is_visitor_fever +
                ", infection_source_type=" + infection_source_type +
                ", investor='" + investor + '\'' +
                ", create_time='" + create_time + '\'' +
                ", update_time='" + update_time + '\'' +
                ", onset_place_detail='" + onset_place_detail + '\'' +
                ", rdt_check_time='" + rdt_check_time + '\'' +
                ", is_transfusion_twoweek=" + is_transfusion_twoweek +
                ", invest_time='" + invest_time + '\'' +
                '}';
    }
}
